package com.wc.AlgoOJ_train.train2_DP训练.c6.DPE016;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/13 23:58
 * @description 光头强的上色1
 * http://43.138.190.70:8888/p/DPE016
 */
public class Main {
    static int maxN = (int) 1e5 + 7;
    static int[] h = new int[maxN];
    static int[] e = new int[maxN << 1];
    static int[] ne = new int[maxN << 1];
    static long[][] dp = new long[maxN][2];
    static boolean[] isNotHead = new boolean[maxN];
    static int idx = 0;
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int n, root;
    static int mod = (int) 1e9 + 7;

    public static void main(String[] args) {
        n = sc.nextInt();
        for (int i = 1; i < n; i++) {
            int u = sc.nextInt();
            int v = sc.nextInt();
            add(u, v);
            add(v, u);
            isNotHead[v] = true;
        }
        for (int i = 1; i <= n; i++) {
            if (!isNotHead[i]) {
                root = i;
                break;
            }
        }
        dfs(root, -1);
        out.println((dp[root][0] + dp[root][1]) % mod);
        out.flush();
    }

    static void add(int u, int v) {
        e[++idx] = v;
        ne[idx] = h[u];
        h[u] = idx;
    }

    static void dfs(int u, int fa) {
        // 说明其是叶子节点
        dp[u][0] = 1;
        dp[u][1] = 1;
        for (int i = h[u]; i != 0; i = ne[i]) {
            int v = e[i];
            // 不走回头路
            if (v == fa) {
                continue;
            }
            dfs(v, u);
            // 当前是0，下一个是0和1都行
            dp[u][0] = dp[u][0] * (dp[v][0] + dp[v][1]) % mod;
            dp[u][1] = dp[u][1] * dp[v][0] % mod;
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }
}
